package com.aso114.project.mvp.activity;

import android.content.Context;
import android.content.Intent;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import com.aso114.project.R;
import com.aso114.project.base.BaseSimpleActivity;
import com.aso114.project.commonview.StickyGridHeadersBaseAdapter;
import com.aso114.project.commonview.StickyGridHeadersGridView;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ShowActivity extends BaseSimpleActivity {
    @BindView(R.id.sgv)
    StickyGridHeadersGridView gv;

    @Override
    protected int getResouseId() {
        return R.layout.griedview;
    }

    @Override
    protected void initView() {
        gv.setAdapter(new StickyGridHeadersBaseAdapter() {

            @Override
            public void unregisterDataSetObserver(DataSetObserver arg0) {

            }

            @Override
            public void registerDataSetObserver(DataSetObserver arg0) {

            }

            @Override
            public boolean isEmpty() {
                return false;
            }

            @Override
            public boolean hasStableIds() {
                return false;
            }

            @Override
            public int getViewTypeCount() {
                return 1;
            }

            @Override
            public View getView(int arg0, View arg1, ViewGroup arg2) {
                final Button b = new Button(getApplicationContext());
                b.setWidth(10);
                b.setHeight(50);
                b.setText(arg0 + "");
                b.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        Toast.makeText(getApplicationContext(), b.getText()+"", 0).show();

                    }
                });
                return b;
            }

            @Override
            public int getItemViewType(int arg0) {
                return 0;
            }

            @Override
            public long getItemId(int arg0) {
                return 0;
            }

            @Override
            public Object getItem(int arg0) {
                return null;
            }

            @Override
            public int getCount() {
                return 100;
            }

            @Override
            public boolean isEnabled(int position) {
                return false;
            }

            @Override
            public boolean areAllItemsEnabled() {
                return false;
            }

            @Override
            public int getNumHeaders() {
                return 10;
            }

            @Override
            public View getHeaderView(int position, View convertView,
                                      ViewGroup parent) {
                Button b = new Button(getApplicationContext());
                b.setWidth(100);
                b.setHeight(50);
                b.setText("KKKKKKHHHH");
                return b;
            }

            @Override
            public int getCountForHeader(int header) {
                return 15;
            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void getBroadcast(Context context, Intent intent) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
